<!--  -->
<template>
  <div class="RankDetail">
    <div class="header">
      <van-icon name="arrow-left" size="18" @click="goBack()" />
      <p>详情</p>
      <span></span>
    </div>
    <div class="content">
      <div class="banner">
        <div class="banner-left">
          <p>{{ DetailData.info }}</p>
          <p class="name">{{ DetailData.name }}</p>
          <p class="phone">
            <van-icon class="phone" name="phone-o" />
            {{ DetailData.phone }}
          </p>
          <p>
            <van-icon name="location-o" />
            {{ DetailData.address }}
          </p>
        </div>
        <div class="banner-right">
          <img
            src="https://img0.baidu.com/it/u=3954163103,2694490546&fm=26&fmt=auto"
            alt=""
          />
        </div>
      </div>
      <div class="list">
        <van-tabs v-model="active">
          <van-tab title="买房">
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>143平/3室 2厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>141平/2室 2厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>199平/3室 2厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
          </van-tab>
          <van-tab title="租房">
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>78平/3室 1厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>91平/2室 2厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
            <dl class="resoldList">
              <dt>
                <img :src="DetailData.img" alt="" />
              </dt>
              <dd>
                <p>{{ DetailData.title }}</p>
                <p>93平/3室 2厅/远洋新天地</p>
                <p>
                  <span>{{ DetailData.price }}万</span>
                  <span>{{ DetailData.num }}/m²</span>
                </p>
                <van-tag color="#ccc" text-color="#000" size="medium"
                  >小区</van-tag
                >
              </dd>
            </dl>
          </van-tab>
          <van-tab title=""></van-tab>
          <van-tab title=""></van-tab>
          <van-tab title="房源：3"></van-tab>
        </van-tabs>
      </div>
    </div>
    <van-goods-action>
      <van-goods-action-icon icon="share-o" text="分享" />
      <van-goods-action-icon icon="" text="" />
      <van-goods-action-icon icon="" text="" />
      <van-goods-action-button
        type="warning"
        text="在线咨询"
        @click="goConsult()"
      />
      <van-goods-action-button
        type="danger"
        text="电话咨询"
        @click="goPhone()"
      />
    </van-goods-action>
  </div>
</template>

<script>
import { getBrokerList } from "@/api";
export default {
  // 组件状态值
  data() {
    return {
      id: "",
      DetailData: [],
      active: 0,
    };
  },
  // 计算属性
  computed: {},
  // 组件方法
  methods: {
    goBack() {
      this.$router.push("/ranking");
    },
    //跳转咨询页面
    goConsult() {
      this.$router.push("/consult");
    },
    //跳转到电话咨询页面
    goPhone() {
      this.$router.push("/phone");
    },
  },
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {
    getBrokerList().then((res) => {
      console.log(res);
      this.id = this.$route.params.id;
      this.DetailData = res.data.data.find((item) => item.id == this.id);
    });
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--使用了scoped属性之后，父组件的style样式将不会渗透到子组件中，-->
<!--然而子组件的根节点元素会同时被设置了scoped的父css样式和设置了scoped的子css样式影响，-->
<!--这么设计的目的是父组件可以对子组件根元素进行布局。-->
<style lang="scss" scoped>
.RankDetail {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.header {
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  color: #fff;
  background: #4381e6;
  padding: 0 15px;
}
.content {
  flex: 1;
  overflow: auto;
  padding: 0 20px;
}
.banner {
  width: 100%;
  display: flex;
  border: 1px solid #ccc;
  border-radius: 20px;
  margin-top: 20px;
  box-shadow: 5px 5px 5px #888888;
  .banner-left {
    width: 50%;
    line-height: 40px;
    padding-left: 10px;
    .name {
      font-size: 20px;
      font-weight: bold;
    }
    .phone {
      font-weight: bold;
    }
  }
  .banner-right {
    width: 50%;
    img {
      width: 100%;
      height: 100%;
      border-radius: 0 20px 20px 0;
    }
  }
}
.list {
  width: 100%;
  margin-top: 20px;
  margin-bottom: 20px;
}
.resoldList {
  width: 100%;
  display: flex;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 20px;
  margin-top: 10px;
  line-height: 20px;
  img {
    width: 100px;
    height: 81px;
    margin-right: 5px;
    // border: 1px solid #000;
  }
  p:nth-child(1) {
    font-weight: bold;
    margin-right: 10px;
  }

  p:nth-child(2) {
    font-size: 12px;
  }
  p:nth-child(3) {
    span:nth-child(1) {
      color: orange;
      margin-right: 10px;
    }
  }
}
</style>
